/**
 * 
 */
package org.wsocket.thread;

import java.io.IOException;
import java.nio.channels.SocketChannel;

import org.apache.log4j.Logger;
import org.wsocket.message.Message;
import org.wsocket.protocol.SocketHandler;

/**
 * SendMessageTask
 * 
 * @author Jeffyd
 */
public class SendMessageTask implements ThreadTask {

	private static Logger log=Logger.getLogger(SendMessageTask.class);
	private int status = 0;

	private Message taskData;

	public SendMessageTask(Message taskData) {
		this.status = ThreadTask.NOT_STARTED;
		this.taskData = taskData;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;

	}

	public void run() {
		SocketChannel sc = taskData.getToConnector().getSocketChannel();
		try {
			SocketHandler.sendResponse(taskData.message, sc);
		} catch (IOException e) {
			log.error(e);
		}
	}

}
